package com.czp.log.action;

import java.util.List;

import com.czp.framework.action.BaseActionSupport;
import com.czp.framework.exception.IServiceException;
import com.czp.framework.listener.OnlineListener;
import com.czp.framework.util.DateUtils;
import com.czp.log.model.Log;
import com.czp.log.service.ILogService;
import com.google.gson.Gson;

/**
 * 【环 境】：J2SE 1.7
 * @author   柴志鹏	CHAIZP@GMAIL.COM
 * @version  version 1.0
 * @since    2014-9-10
 */
public class LogAction extends BaseActionSupport {
	private static final long serialVersionUID = 2546367486869950215L;
	private ILogService logService;
	
	/** 
	 * 【描 述】：查询日志信息集合
	 */
	public void queryLogInfoList() {
		Log log = new Log();
		try {
			log.setStart(Integer.parseInt(request.getParameter("start")));
			log.setLimit(Integer.parseInt(request.getParameter("limit")));
			log.setStartTime(DateUtils.getTimestamp(request.getParameter("startTime")));
			log.setEndTime(DateUtils.getTimestamp(request.getParameter("endTime")));
			log.setStatus(request.getParameter("status"));
			this.responseOutPrint(logService.queryLogInfoList(log));
		} catch(Exception e) {
			throw new IServiceException(this.getClass()+ "queryLogInfoList", e);
		}
	}
	
	/** 
	 * 【描 述】：查询当前在线用户
	 */
	public void queryOnlineUsers() {
		try {
			List<Object> users = OnlineListener.getSessions();
			this.responseOutPrint(new Gson().toJson(users));
		} catch(Exception e) {
			throw new IServiceException(this.getClass()+ "queryOnlineUsers", e);
		}
	}
	
	/**
	 * 获取 logService
	 * @return 返回 logService
	 */
	public ILogService getLogService() {
		return logService;
	}
	/**
	 * 设置 logService
	 * @param 对logService进行赋值
	 */
	public void setLogService(ILogService logService) {
		this.logService = logService;
	}
	
}
